﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WPFCABShell.Shell.Interface.Services.Command;
using Microsoft.Practices.ObjectBuilder;
using WPF = System.Windows.Input;

namespace Shortcuts
{
	/// <summary>
	/// Interaction logic for CommandsView.xaml
	/// </summary>
	public partial class CommandsView : UserControl, ICommandsView
	{
		private bool _isAccepted;

		public static readonly DependencyProperty CommandServiceProperty = DependencyProperty.Register("CommandService",
			typeof(ICommandService),
			typeof(CommandsView));

		[Dependency(NotPresentBehavior = NotPresentBehavior.Throw)]
		public ICommandService CommandService
		{
			get
			{
				return GetValue(CommandServiceProperty) as ICommandService;
			}
			set
			{
				SetValue(CommandServiceProperty, value);
			}
		}

		public bool IsAccepted
		{
			get
			{
				return _isAccepted;
			}
		}

		public IEnumerable<ICommand> SelectedCommands
		{
			get
			{
				foreach (ICommand command in _commandsListBox.SelectedItems)
				{
					yield return command;
				}
			}
		}

		public CommandsView()
		{
			InitializeComponent();
		}

		private void _okButton_Click(object sender, EventArgs e)
		{
			Debug.Assert(Parent is Window);
			_isAccepted = true;
			(Parent as Window).DialogResult = true;
		}
	}
}
